Ext.namespace('Divo');
Ext.namespace('Divo.app');

Divo.app.PersonForm = Ext.extend(Divo.Base.EditForm, {
      fields : new Ext.util.MixedCollection(),
      dataRecordMeta : Ext.data.Record.create([{
            name : "_p_record_status",
            type : "string"
          }, {
            name : "id",
            type : "float"
          }, {
            name : "name",
            type : "string"
          }, {
            name : "number",
            type : "string"
          }, {
            name : "sex",
            type : "string"
          }, {
            name : "type",
            type : "string"
          }, {
            name : "area",
            type : "string"
          }]),
      initComponent : function() {
        var me = this;
        var tn = 1;

        this.fields.add("_p_record_status", new Ext.form.Hidden({
                  name : "_p_record_status"
                }));
        this.fields.add("id", new Ext.form.Hidden({
                  name : "id",
                  dataIndex : "id",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("type", new Ext.form.Hidden({
                  name : "type",
                  dataIndex : "type",
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("name", new app.base.TextField({
                  name : "name",
                  dataIndex : "name",
                  fieldLabel : "病人姓名",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("number", new app.base.TextField({
                  name : "number",
                  dataIndex : "number",
                  fieldLabel : "病人住院号",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        this.fields.add("area", new app.base.TextField({
                  name : "area",
                  dataIndex : "area",
                  fieldLabel : "所在病区",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  insert_allowed : true,
                  update_allowed : true
                }));
        var para = [[1, "医保"], [2, "自费"]];
        this.fields.add("typeG", new app.base.ComboBox({
                  fieldLabel : '病人类型',
                  name : 'typeG',
                  store : Divo.com.Lib.getStaticDateDs(para),
                  displayField : 'name',
                  dataIndex : 'typeG',
                  mode : 'remote',
                  typeAhead : false,
                  forceSelection : true,
                  loadingText : '正在搜索...',
                  listWidth : 220,
                  width : 80,
                  pageSize : 10,
                  minChars : 0,
                  hideTrigger : false,
                  allowBlank : false,
                  labelSeparator : ":*",
                  insert_allowed : true,
                  update_allowed : true,
                  editable : false,
                  value : "医保",
                  onSelect : function(record) {
                    var data = record.data;
                    this.setValue(data.name);
                    me.setFieldValue("type", data.id);
                    // grid.getStore().load();
                    this.onTriggerClick();
                  }
                }));
        this.fields.add("sexG", new Ext.form.RadioGroup({
                  name : "sexG",
                  dataIndex : "sexG",
                  fieldLabel : "性别",
                  allowBlank : false,
                  labelSeparator : ":*",
                  tabIndex : tn++,
                  width : 150,
                  defaultType : 'radio',
                  items : [{
                        checked : true,
                        fieldLabel : '',
                        boxLabel : '男',
                        name : 'sex',
                        inputValue : '1'
                      }, {
                        fieldLabel : '',
                        labelSeparator : '',
                        boxLabel : '女',
                        name : 'sex',
                        inputValue : '2'
                      }],
                  insert_allowed : true,
                  update_allowed : true
                }));
        Ext.apply(this, {
              items : [this.fields.get("_p_record_status"), {
                layout : "form",
                columnWidth : 1,
                labelAlign : "right",
                labelWidth : 100,
                items : [this.fields.get("id"), this.fields.get("number"),
                    this.fields.get("type"), this.fields.get("name"),
                    this.fields.get("sexG"), this.fields.get("typeG"),
                    this.fields.get("area")]
              }],
              border : false,
              frame : true,
              firstFocusFieldName : "number"
            });

        Divo.app.PersonForm.superclass.initComponent.apply(this, arguments);
      }

      ,
      onRender : function() {
        Divo.app.PersonForm.superclass.onRender.apply(this, arguments);
      },
      newDataRecord : function() {
        return new this.dataRecordMeta({
              _p_record_status : "insert",
              id : "",
              name : "",
              number : "",
              sexG : "",
              typeG : "",
              type : "",
              area : ""
            });
      }

    });
Ext.reg("Divo.app.PersonForm", Divo.app.PersonForm);